home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1994
/
MacHack 1994.toast
/
MacHack™94
/
Talks & Papers
/
Timothy Knox
/
yerk 3.66
/
Module source
/
logging
< prev
next >
Wrap
Text File
|
1994-06-24
|
2KB
|
56 lines
\ 5/23/93 rfl Module to echo output to a file
\ vector output to a file like +print, -print
\ will append to existing file
\ hold option key down to select fileName and destination....default named
\ 'logfile' in the yerk folder.
:Module logMod
file logfile \ don't want this closed on abort. or do i?
: typefile write: logfile drop ;
: emitfile buf255 c! buf255 1 typefile ;
: crfile 13 emitfile ;
: echofile ( -- ) \ should work like +print, but to a file?
'c typefile -> ptypevec \ type to the file instead of the printer
0 -> typevec \ leave the screen alone
'c emitfile -> pemitvec \ emit to the file
'c crfile -> pcrvec ; \ cr to file, also
: tofile ( -- ) \ should send all output to the file
'c typefile -> typevec
'c emitfile -> emitvec
'c crfile -> crvec ;
: toscreen ( -- ) \ back to normal
'c 2drop -> ptypevec
0 -> typevec
0 -> emitvec
0 -> crvec ;
: nolog toScreen 0 -> pemitVec 0 -> pcrVec ;
scon DefName "logFile"
\ logging word to create a file to test with
\ returns true if open, false if cancelled by user
: openlog ( -- b) option?
IF " Save output to File…" DefName stdPut: logfile \ select a file
ELSE DefName name: logfile true \ default to Yerk folder
THEN dup
IF open: logfile konstant fnfErr = \ want to append to existing file
IF create: logFile drop THEN
last: logfile \ move to end of file
THEN ;
: closelog nolog
txType saveSig set: logfile
close: logfile drop ;
: +file openlog IF echofile THEN ;
: -file closelog ;
: toFile null ;
;Module